________________________________________________________________________ Chapter 9: Colors 69 ________________________________________________________________________ CHAPTER NINE: COLORS Some PADtalk properties and commands require that you specify a color. Traditionally on personal computers, colors are represented by a foreground color and a background color combination, or attribute. There are always 256 attributes available in character mode, but these are translated by some hardware systems to black and white. Colors 0 to 127 are normal intensity combinations, and colors 128 to 255 are high intensity combinations. There are 16 possible colors, each corresponding to a number. Each color can be used as a background or foreground (16*16=256). 0 black 8 dark grey 1 blue 9 light blue 2 green 10 light green 3 cyan 11 light cyan 4 red 12 light red 5 magenta 13 light magenta 6 brown 14 light brown 7 grey 15 white SPECIFYING COLORS The color names from this table can be used to specify a color in an English-like manner, as in the following example: set the fillColor of button 1 to red; set the acceleratorColor of pg btn "help" to light red; put yellow into myColor; You can combine the color keywords using the word on to form a foreground/background attribute specification. When no background is specified, black is assumed. The syntax for such a combination is as follows: on ________________________________________________________________________ Chapter 9: Colors 70 ________________________________________________________________________ For example, the following statement sets the fill color of button 1 to be light blue background with red lettering. set the fillColor of button 1 to red on light blue; COLOR NUMBERS The color constants are translated by HyperPAD to single numbers between 0 and 255 using the following formula: color = (background * 16) + foreground For example, the color red on white translates to: color = (white * 16) + red color = (15 * 16) + 4c color = 244 Thus, the following two statements are equivalent: set the fillColor of button 1 to red on white; set the fillColor of button 1 to 244; Representing colors as numbers allows you to algorithmically adjust the colors of objects, as in the following example: -- ask for the foreground color number ask "type in foreground color number"; put it into fcolor; -- ask for the background color number ask "type in background color number"; put in into bcolor; -- set the color set the color of page field 1 to (bcolor * 16) + fcolor; The colors available are determined by the graphics card and monitor used. The color constants 0 through 7 are low intensity, whereas colors 8 through 15 are high intensity. On some monitors, you may need to finely adjust the contrast to see the high intensity colors. Using a high intensity color as a background is blinking on most hardware configurations. HyperPAD disables this blinking capability to provide you with the maximum number of color combinations (256). You can specify the higher intensity colors using the word blinking: set the color of button 1 to blinking grey on red; ________________________________________________________________________ Chapter 9: Colors 71 ________________________________________________________________________ When you design pads for monochrome systems, all of the 256 available colors are translated to black and white. In general, it is safe to use the following color combinations: color 7 (grey) white on black color 112 (black on grey) reverse video These are the default colors for all objects. On LCD systems, such as some laptops, the color combinations may be different.